<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css">
  <script src="/lib/pace/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"sekla.cn","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"right","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":"valine","storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="实验题目预备实验1： 安装Linux环境，并进行简单程序的编译和GDB调试。 实验目的熟悉Linux系统的基本操作，安装与虚拟机的配置使用，在linux环境下的编程与编译，学习x86 debug工具的使用，简单gdb命令使用。">
<meta property="og:type" content="article">
<meta property="og:title" content="gdb基本操作等简单指令">
<meta property="og:url" content="http://sekla.cn/2021/04/14/csapp-lab0/index.html">
<meta property="og:site_name" content="Sekla&#39;s Blog">
<meta property="og:description" content="实验题目预备实验1： 安装Linux环境，并进行简单程序的编译和GDB调试。 实验目的熟悉Linux系统的基本操作，安装与虚拟机的配置使用，在linux环境下的编程与编译，学习x86 debug工具的使用，简单gdb命令使用。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://i.loli.net/2021/04/14/TLYS68dCNucZEpU.png">
<meta property="og:image" content="https://i.loli.net/2021/04/14/dWxvP5ih2ULQtZR.png">
<meta property="og:image" content="https://i.loli.net/2021/04/14/MF2Z4EVTo1sPwXY.png">
<meta property="og:image" content="https://i.loli.net/2021/04/14/dcTIUXCaqG1spfR.png">
<meta property="og:image" content="https://i.loli.net/2021/04/14/6ucArL8k5POfNJI.png">
<meta property="og:image" content="https://i.loli.net/2021/04/14/piHdNWoMBkl9QUt.png">
<meta property="og:image" content="https://i.loli.net/2021/04/14/HpGu9eaFn5fUMTR.png">
<meta property="og:image" content="https://i.loli.net/2021/04/14/Zi3FzaAdTKQNf9P.png">
<meta property="og:image" content="https://i.loli.net/2021/04/14/ziChLogHBMRlkyx.png">
<meta property="og:image" content="https://i.loli.net/2021/04/14/nbileYh831Vt7BM.png">
<meta property="og:image" content="https://i.loli.net/2021/04/14/4thWPzFEN5kA789.png">
<meta property="og:image" content="https://i.loli.net/2021/04/14/QOfZwIh6mJdUCx8.png">
<meta property="og:image" content="https://i.loli.net/2021/04/14/uSRYHEOh1qWaPUQ.png">
<meta property="og:image" content="https://i.loli.net/2021/04/14/bET36Ka1rLdz7D9.png">
<meta property="og:image" content="https://i.loli.net/2021/04/14/21WdIiK3owSzqmP.png">
<meta property="article:published_time" content="2021-04-14T08:39:04.000Z">
<meta property="article:modified_time" content="2021-10-18T14:42:40.394Z">
<meta property="article:author" content="Sekla">
<meta property="article:tag" content="Linux">
<meta property="article:tag" content="gdb">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://i.loli.net/2021/04/14/TLYS68dCNucZEpU.png">

<link rel="canonical" href="http://sekla.cn/2021/04/14/csapp-lab0/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>gdb基本操作等简单指令 | Sekla's Blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

  <script type="text/javascript" src="/js/my_js/clicklove.js"></script>
<!-- hexo injector head_end start -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css">

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hexo-math@4.0.0/dist/style.css">
<!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Sekla's Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Keep Learning Keep Doing</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签<span class="badge">14</span></a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类<span class="badge">23</span></a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">100</span></a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://sekla.cn/2021/04/14/csapp-lab0/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="Sekla">
      <meta itemprop="description" content="Sekla">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Sekla's Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          gdb基本操作等简单指令
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-04-14 16:39:04" itemprop="dateCreated datePublished" datetime="2021-04-14T16:39:04+08:00">2021-04-14</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-10-18 22:42:40" itemprop="dateModified" datetime="2021-10-18T22:42:40+08:00">2021-10-18</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%B3%BB%E7%BB%9F/" itemprop="url" rel="index"><span itemprop="name">计算机系统</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%B3%BB%E7%BB%9F/CSAPP%E5%AE%9E%E9%AA%8C%E7%B3%BB%E5%88%97/" itemprop="url" rel="index"><span itemprop="name">CSAPP实验系列</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span><br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>2.3k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>2 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="实验题目"><a href="#实验题目" class="headerlink" title="实验题目"></a>实验题目</h2><p>预备实验1：</p>
<p>安装Linux环境，并进行简单程序的编译和GDB调试。</p>
<h2 id="实验目的"><a href="#实验目的" class="headerlink" title="实验目的"></a>实验目的</h2><p>熟悉Linux系统的基本操作，安装与虚拟机的配置使用，在linux环境下的编程与编译，学习x86 debug工具的使用，简单gdb命令使用。</p>
<a id="more"></a>

<h2 id="实验环境"><a href="#实验环境" class="headerlink" title="实验环境"></a>实验环境</h2><p>Ubuntu 32bit</p>
<h2 id="实验内容"><a href="#实验内容" class="headerlink" title="实验内容"></a>实验内容</h2><h3 id="第一步，在你所使用的电脑平台上安装Linux系统与环境；"><a href="#第一步，在你所使用的电脑平台上安装Linux系统与环境；" class="headerlink" title="第一步，在你所使用的电脑平台上安装Linux系统与环境；"></a>第一步，在你所使用的电脑平台上安装Linux系统与环境；</h3><p><strong>具体流程:</strong></p>
<p>1.安装虚拟机环境，下载VMware Workstation。</p>
<p><a target="_blank" rel="noopener" href="https://www.vmware.com/cn/products/workstation-pro.html%E8%BF%9B%E5%85%A5%E5%AE%98%E7%BD%91%E4%B8%8B%E8%BD%BD%EF%BC%8C%E7%A4%BE%E5%8C%BA%E7%89%88%E5%8F%AF%E5%85%8D%E8%B4%B9%E4%BD%BF%E7%94%A8%E3%80%82">https://www.vmware.com/cn/products/workstation-pro.html进入官网下载，社区版可免费使用。</a></p>
<p>下载完毕进行安装配置，需要下载Linux镜像，实验要求为32bit。</p>
<p>2.安装Linux</p>
<p>下载完Linux镜像后，直接拖入VMware进行安装，根据需求进行配置，分配内存硬盘。</p>
<p>3.配置Linux</p>
<p>初次进入Linux需要设置密码，设置完毕后由于国外下载源速度过慢，语言默认为英文，中文设置需要进行下载。</p>
<p>进行更换下载源操作，这里使用清华大学提供的ubuntu镜像：</p>
<p><a target="_blank" rel="noopener" href="https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/">https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/</a></p>
<p>选择版本12.04LTS，找到配置文件目录为/etc/apt/sources.list，尝试进行修改，由于etc目录不在/home下，</p>
<p>输入<code>cd /</code>返回总目录后输入<code>vi /etc/apt/sources.list</code>开始编辑，这里要注意vim的用法以及linux下复制粘贴为Ctrl+Shift+v/c。</p>
<p>更换源后进行<code>apt-get update</code>速度明显增快。</p>
<h4 id="问题："><a href="#问题：" class="headerlink" title="问题："></a>问题：</h4><p>1.<code>vi /etc/apt/sources.list</code>提示权限不足</p>
<p>切换成root状态，或直接在图形界面进行更改，<code>sudo su</code>可简单获取root权限。或者运用<code>chmod</code>更改文件权限状态，不建议这么做。</p>
<p>第一步到此结束。</p>
<h3 id="第二步，成功在linux系统中使用gcc完成简单c语言的编译和执行；"><a href="#第二步，成功在linux系统中使用gcc完成简单c语言的编译和执行；" class="headerlink" title="第二步，成功在linux系统中使用gcc完成简单c语言的编译和执行；"></a>第二步，成功在linux系统中使用gcc完成简单c语言的编译和执行；</h3><p>以Hello.c文件为例子</p>
<p>1.创建新的目录用于保存代码及生成</p>
<p>首先Ctr+Alt+T快速打开终端后，进行mkdir指令操作，如果想要知道当前目录位置，可以输入pwd指令。</p>
<p>并用cd指令进入目录。</p>
<p><img src="https://i.loli.net/2021/04/14/TLYS68dCNucZEpU.png" alt="1"></p>
<p>2.创建Hello.c空文件并进行编辑。</p>
<p>输入<code>touch hello.c</code>并<code>vi hello.c</code>，对hello.c进行编辑，这里需要简单学习vim使用。</p>
<p>vim分为三种模式，命令模式，输入模式，底线命令模式。</p>
<p>刚启动vim则进入命令模式，此时输入不会编辑文件，输入i可以进入输入模式开始编辑，常用命令：</p>
<p>​    <strong>1.i</strong>切换输入模式</p>
<p>​    <strong>2.x</strong>删除当前光标所在字符</p>
<p>​    **3.**：用来切换到底线命令模式</p>
<p><strong>输入模式</strong>:</p>
<p>注意DEL可删除光标后一个字符，Backspace为删除前一个字符，用方向键移动光标，常用Home/End键，Page up/down进行翻页操作，Insert可切换输入或替换模式，ESC退出输入模式，其余操作与Windows一样。</p>
<p><strong>底线命令模式</strong></p>
<p>q退出程序，w保存文件。</p>
<p><img src="https://i.loli.net/2021/04/14/dWxvP5ih2ULQtZR.png" alt="2"></p>
<p>编写好文件后保存。</p>
<p>3.Hello.c的编译</p>
<p>a.预处理</p>
<p>​    将所有的宏，头文件展开，去掉注释，生成.i文件。</p>
<p>​    <code>gcc -E hello.c -o hello.i</code>，再用cat指令进行查看。</p>
<p><img src="https://i.loli.net/2021/04/14/MF2Z4EVTo1sPwXY.png" alt="3"></p>
<p>b.编译</p>
<p>​    将高级语言翻译成汇编语言的过程，<code>gcc -S hello.i -o hello.s</code>查看可以得到汇编代码。</p>
<p><img src="https://i.loli.net/2021/04/14/dcTIUXCaqG1spfR.png" alt="4"></p>
<p>c.汇编</p>
<p>​    将汇编语言转换为二进制形式的机器语言，<code>gcc -c hello.s -o hello.o</code>，此时不能直接查看文件，需要通关专用软件如Ghex查看，此时已经安装好。</p>
<p><img src="https://i.loli.net/2021/04/14/6ucArL8k5POfNJI.png" alt="5"></p>
<p>d.链接</p>
<p>​    将分别编译完成的.o文件链接起来<code>gcc hello.o -o hello</code></p>
<p>此时运用./hello即可运行输出hello world</p>
<p><img src="https://i.loli.net/2021/04/14/piHdNWoMBkl9QUt.png" alt="6"></p>
<h4 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h4><p>1.尽量不要获取root后创建文件，可能会导致各种权限问题。</p>
<p>2.注意命令使用的格式：命令 [参数] 目标文件 输出文件 </p>
<h3 id="第三步，使用GDB进行程序基本的程序调试和反汇编。"><a href="#第三步，使用GDB进行程序基本的程序调试和反汇编。" class="headerlink" title="第三步，使用GDB进行程序基本的程序调试和反汇编。"></a>第三步，使用GDB进行程序基本的程序调试和反汇编。</h3><p>1.gdb进行调试</p>
<p>首先创建测试文件与代码：</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;stdio.h&gt;</span></span></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">add_range</span><span class="params">(<span class="keyword">int</span> low, <span class="keyword">int</span> high)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">int</span> i, sum;</span><br><span class="line">	<span class="keyword">for</span> (i = low; i &lt;= high; i++)</span><br><span class="line">		sum = sum + i;</span><br><span class="line">	<span class="keyword">return</span> sum;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">int</span> result[<span class="number">100</span>];</span><br><span class="line">	result[<span class="number">0</span>] = add_range(<span class="number">1</span>, <span class="number">10</span>);</span><br><span class="line">	result[<span class="number">1</span>] = add_range(<span class="number">1</span>, <span class="number">100</span>);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;result[0]=%d\nresult[1]=%d\n&quot;</span>, result[<span class="number">0</span>], result[<span class="number">1</span>]);</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>最后结果应该是result[0]=55，result[1]=5050；</p>
<p>编译并运行代码，会发现结果相去甚远，此时可以运用gdb调试，<code>gcc -g gdbtest.c -o gdbtest</code>加入-g参数才可进行gdb调试。</p>
<p><img src="https://i.loli.net/2021/04/14/HpGu9eaFn5fUMTR.png" alt="7"></p>
<p><strong>开始gdb调试：</strong></p>
<p><img src="https://i.loli.net/2021/04/14/Zi3FzaAdTKQNf9P.png" alt="8"></p>
<p><strong>逐句运行：</strong></p>
<p><img src="https://i.loli.net/2021/04/14/ziChLogHBMRlkyx.png" alt="9"></p>
<p><strong>step指令跟踪函数：</strong></p>
<p><img src="https://i.loli.net/2021/04/14/nbileYh831Vt7BM.png" alt="10"></p>
<p>step后可以接函数名，双击tab可自动补全。</p>
<p>*<em>backtrace查看调用帧栈，info查看局部变量值，frame查看帧栈值</em><img src="https://i.loli.net/2021/04/14/4thWPzFEN5kA789.png" alt="11"></p>
<p><strong>print打印变量值,finish运行至结束:</strong></p>
<p><img src="https://i.loli.net/2021/04/14/QOfZwIh6mJdUCx8.png" alt="15"></p>
<p><strong>继续step与print rusult发现函数赋值没有问题，可以明显发现是因为没有给sum初始化导致错误，修改文件后运行：</strong></p>
<p><img src="https://i.loli.net/2021/04/14/uSRYHEOh1qWaPUQ.png" alt="12"></p>
<p>若不退出gdb也可对sum进行修改：</p>
<p><code>set var sum=0</code>后<code>finish</code>，<code>next</code>也可以得到结果。</p>
<p>2.反汇编</p>
<p>对hello.c进行反汇编</p>
<p><code>objdump</code>指令：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">objdump -d hello.o</span><br><span class="line">反汇编程序</span><br><span class="line">objdump -f hello.o</span><br><span class="line">显示头文件</span><br></pre></td></tr></table></figure>

<p><img src="https://i.loli.net/2021/04/14/bET36Ka1rLdz7D9.png" alt="13"></p>
<p><img src="https://i.loli.net/2021/04/14/21WdIiK3owSzqmP.png" alt="14"></p>

    </div>
    
    
    

      <footer class="post-footer">
          
          <div class="post-tags">
              <a href="/tags/Linux/" rel="tag"><i class="fa fa-tag"></i> Linux</a>
              <a href="/tags/gdb/" rel="tag"><i class="fa fa-tag"></i> gdb</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/04/14/c++houjie1/" rel="prev" title="侯捷C++高级面向对象上简单笔记">
      <i class="fa fa-chevron-left"></i> 侯捷C++高级面向对象上简单笔记
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/04/15/csapp-datalab/" rel="next" title="CSAPP-datalab">
      CSAPP-datalab <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%9E%E9%AA%8C%E9%A2%98%E7%9B%AE"><span class="nav-number">1.</span> <span class="nav-text">实验题目</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%9E%E9%AA%8C%E7%9B%AE%E7%9A%84"><span class="nav-number">2.</span> <span class="nav-text">实验目的</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%9E%E9%AA%8C%E7%8E%AF%E5%A2%83"><span class="nav-number">3.</span> <span class="nav-text">实验环境</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%9E%E9%AA%8C%E5%86%85%E5%AE%B9"><span class="nav-number">4.</span> <span class="nav-text">实验内容</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%AC%AC%E4%B8%80%E6%AD%A5%EF%BC%8C%E5%9C%A8%E4%BD%A0%E6%89%80%E4%BD%BF%E7%94%A8%E7%9A%84%E7%94%B5%E8%84%91%E5%B9%B3%E5%8F%B0%E4%B8%8A%E5%AE%89%E8%A3%85Linux%E7%B3%BB%E7%BB%9F%E4%B8%8E%E7%8E%AF%E5%A2%83%EF%BC%9B"><span class="nav-number">4.1.</span> <span class="nav-text">第一步，在你所使用的电脑平台上安装Linux系统与环境；</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E9%97%AE%E9%A2%98%EF%BC%9A"><span class="nav-number">4.1.1.</span> <span class="nav-text">问题：</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%AC%AC%E4%BA%8C%E6%AD%A5%EF%BC%8C%E6%88%90%E5%8A%9F%E5%9C%A8linux%E7%B3%BB%E7%BB%9F%E4%B8%AD%E4%BD%BF%E7%94%A8gcc%E5%AE%8C%E6%88%90%E7%AE%80%E5%8D%95c%E8%AF%AD%E8%A8%80%E7%9A%84%E7%BC%96%E8%AF%91%E5%92%8C%E6%89%A7%E8%A1%8C%EF%BC%9B"><span class="nav-number">4.2.</span> <span class="nav-text">第二步，成功在linux系统中使用gcc完成简单c语言的编译和执行；</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E9%97%AE%E9%A2%98"><span class="nav-number">4.2.1.</span> <span class="nav-text">问题</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E7%AC%AC%E4%B8%89%E6%AD%A5%EF%BC%8C%E4%BD%BF%E7%94%A8GDB%E8%BF%9B%E8%A1%8C%E7%A8%8B%E5%BA%8F%E5%9F%BA%E6%9C%AC%E7%9A%84%E7%A8%8B%E5%BA%8F%E8%B0%83%E8%AF%95%E5%92%8C%E5%8F%8D%E6%B1%87%E7%BC%96%E3%80%82"><span class="nav-number">4.3.</span> <span class="nav-text">第三步，使用GDB进行程序基本的程序调试和反汇编。</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Sekla"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">Sekla</p>
  <div class="site-description" itemprop="description">Sekla</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">100</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">23</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/ShenTiao" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;ShenTiao" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:584892986@qq.com" title="E-Mail → mailto:584892986@qq.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>



      </div>

      <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=1416875904&auto=0&height=66"></iframe>
      
    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Sekla</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
    <span title="站点总字数">288k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">4:22</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script size="300" alpha="0.6" zIndex="-1" src="/lib/canvas-ribbon/canvas-ribbon.js"></script>
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  
      

<script>
  if (typeof MathJax === 'undefined') {
    window.MathJax = {
      loader: {
        source: {
          '[tex]/amsCd': '[tex]/amscd',
          '[tex]/AMScd': '[tex]/amscd'
        }
      },
      tex: {
        inlineMath: {'[+]': [['$', '$']]},
        tags: 'ams'
      },
      options: {
        renderActions: {
          findScript: [10, doc => {
            document.querySelectorAll('script[type^="math/tex"]').forEach(node => {
              const display = !!node.type.match(/; *mode=display/);
              const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
              const text = document.createTextNode('');
              node.parentNode.replaceChild(text, node);
              math.start = {node: text, delim: '', n: 0};
              math.end = {node: text, delim: '', n: 0};
              doc.math.push(math);
            });
          }, '', false],
          insertedScript: [200, () => {
            document.querySelectorAll('mjx-container').forEach(node => {
              let target = node.parentNode;
              if (target.nodeName.toLowerCase() === 'li') {
                target.parentNode.classList.add('has-jax');
              }
            });
          }, '', false]
        }
      }
    };
    (function () {
      var script = document.createElement('script');
      script.src = '//cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js';
      script.defer = true;
      document.head.appendChild(script);
    })();
  } else {
    MathJax.startup.document.state(0);
    MathJax.texReset();
    MathJax.typeset();
  }
</script>

    

  

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/live2dw/assets/shizuku.model.json"},"display":{"position":"left","width":250,"height":500},"mobile":{"show":false},"react":{"opacity":0.9},"log":false});</script></body>
</html>

<script type="text/javascript" src="/js/src/love.js"></script>
